<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>学生签到详情</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="./layui/css/layui.css">
	<script type="text/javascript" src="./layui/layui.js" charset="UTF-8"></script>
	<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<div class="layui-inline">
      	<label class="layui-form-label">签到ID</label>
      	<div class="layui-input-block">
       		<input type="text" name="checkid" id="checkid" autocomplete="off" class="layui-input">
      	</div>
    </div>
    <div class="layui-inline">
      	<button class="layui-btn" data-type="reload" id="search">搜索</button>
    </div>
  	<table class="layui-hide" id="test" lay-filter="test"></table>    
	<script>
		layui.use(['table','layer'], function(){
		  	var $ = layui.jquery
		  	,table = layui.table
		  	,layer = layui.layer;
		  	
		  	
		  	//添加课程，数据表格重加载
			//搜索，加载表格
			$('#search').on('click',function(){
		  		var demoReload = $("#checkid").val();
		  		
		  	//动态表格，获取数据库数据
		  	var tableIns = table.render({
				elem: '#test'
				,id: 'test'
				,url: 'GetCheckDetail.do'
				,where: {
		  				'checkid':demoReload
		  			}
				,toolbar:  '#toolbarDemo'
				,defaultToolbar: ['filter', 'exports', 'print']
				,title: '查看课程对应的签到'
				,page:true
				,limit:4
				,limits:[2,3,4,5,6]
				,cols: [[
					{type:'numbers',width:80}
			  		,{field:'checkid', title:'签到ID'}
			  		,{field:'studentid', title:'学生ID'}
			  		,{field:'studentname', title:'学生姓名'}
			        ,{fixed: 'right', width: 150, align:'center', toolbar: '#barDemo'}
					]],
				parseData:function(res) {
					var result;
	                if (this.page.curr)
	                	result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
	                else
	                    result = res.data.slice(0, this.limit);
	               	return {
	               		"code": res.code, //解析接口状态
	               		"msg": res.msg, //解析提示文本
	               		"data": res.data
	               		};
	               	}
			});
		  	});
			
			//删除&&查看&&编辑
			table.on('tool(test)', function(obj){
				var data = obj.data;
				if(obj.event === 'addCheck'){
					layer.confirm('开启签到？', function(index){
						obj.del();
						$.ajax({
							url:'AddCheck.do'
							,data:{
								courseid:data.courseid
							}
						});
						layer.msg("发布成功");
						layer.close(index);
					});
				} else if(obj.event === 'addStudent') {
					layer.open({
		            	type: 2 
		            	,title: '添加学生'
		            	,area: ['800px', '600px']
		            	,content:['addStudent.jsp']
		            	,data:{
		            	courseid:data.courseid}
		            	,maxmin: true
		            	,btn: ['关闭']
		        		,yes: function(){
		    				layer.closeAll();
		        		}
		        		,end:function(){
		        			location.reload();
		        		}
		          	}); 
				} else if(obj.event === 'allCheck') {
					layer.open({
		            	type: 2 
		            	,title: '课程学生列表'
		            	,area: ['800px', '600px']
		            	,content:['allCheck.do']
		            	,maxmin: true
		            	,btn: ['关闭']
		        		,yes: function(){
		    				layer.closeAll();
		        		}
		        		,end:function(){
		        			location.reload();
		        		}
		          	}); 
				}
			});
	})
	</script>
</body>
</html>